
let data = new class {
  // 导入导出任务数目统计

  constructor () {
    this.dataSecret = []
    this.dataNosecret = []
  }

  setConfig (param) {
    // 为整个类设置个性化参数
    return this
  }

  async getData (dataType) {
    let { success, data } = {
      success:true,
      data:{

      }
    }
    return { success, data }
  }

  /**
   * 返回导入导出数目统计
   * */
  async createData () {
    let me = this
    let { success, data } = await this.getData()
    if (success) {
      const currentNet = capp.curNetType
      let netWorkArr = [...capp.network] //深拷贝，避免remove操作后network数组变化
      let otherNetArr = _.remove(netWorkArr, function (n) {
        return n.value != currentNet
      })
      let seriesData = {}
      _.forEach(otherNetArr, function (v, i) {
        seriesData[v.des] = {}
        seriesData[v.des].name = ''
        seriesData[v.des].data = []
        _.forEach(data, function (v2, i2) {
          if ((v2.toType == v.value && v2.fromType == currentNet) || (v2.fromType == v.value && v2.toType == currentNet)) {
            v2.value = v2.count

            if (v2.fromType == currentNet) {
              v2.name = capp.currentNetWork.name + '导出'
            } else {
              v2.name = '导入' + capp.currentNetWork.name
            }
            seriesData[v.des].des = v.name
            seriesData[v.des].data.push(v2)
          }

        })
      })
      return seriesData
    } else {
      throw new Error('出错了')
    }
  }

  /**
   * 返回导入导出比例数据
   * */
  async createDataPercent () {
    let data=await this.createData()
    _.forEach(data,function (v,i) {
      let totalNum=0
      _.forEach(v.data,function (dataItem) {
        totalNum+=parseInt(dataItem.count)
      })
      _.forEach(v.data,function (dataItem) {
        dataItem.percent=Math.round(dataItem.count/totalNum*10000)/100+'%'
        dataItem.totalNum=totalNum
      })
    })
    return data
  }
}
export {
  data
}
